import request from '@/utils/request';
import type {
  SystemConfig,
  UpdateConfigRequest,
  UploadResponse,
} from '@/types/config';

// 获取系统配置
export const getConfig = (): Promise<SystemConfig> => {
  return request.get('/admin/config');
};

// 更新系统配置
export const updateConfig = (data: UpdateConfigRequest): Promise<SystemConfig> => {
  return request.put('/admin/config', data);
};

// 上传楼层导览图片
export const uploadFloorGuideImage = (file: File): Promise<UploadResponse> => {
  const formData = new FormData();
  formData.append('file', file);
  return request.post('/admin/config/upload/floor-guide', formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
};

// 上传视频文件
export const uploadVideo = (file: File): Promise<UploadResponse> => {
  const formData = new FormData();
  formData.append('file', file);
  return request.post('/admin/config/upload/video', formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
};

// 重置系统配置
export const resetConfig = (): Promise<{ message: string }> => {
  return request.post('/admin/config/reset');
};
